package org.springcloud.wisdom.spring_01_canteen.student;

import org.springcloud.wisdom.spring_01_canteen.common.bean.ResponseData;
import org.springcloud.wisdom.spring_01_canteen.login.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;

    // 根据 ID 获取学生信息
    @PutMapping("/getById")
    public ResponseData<Student> getStudentById(@RequestParam("id") Integer id) {
        Student student = studentService.getStudentById(id);
        if (student != null) {
            return new ResponseData<>(200, "查询成功", student);
        } else {
            return new ResponseData<>(400, "未找到学生信息", null);
        }
    }
}
